package com.shaoxi.risk.domain.service.impl;

import com.shaoxi.risk.api.req.PriceRiskReq;
import com.shaoxi.risk.domain.ability.CostPriceQueryAbility;
import com.shaoxi.risk.domain.ability.PromotionPriceCalAbility;
import com.shaoxi.risk.domain.context.PriceRiskContext;
import com.shaoxi.risk.domain.model.RiskDisposalResult;
import com.shaoxi.risk.domain.model.RiskEvent;
import com.shaoxi.risk.domain.model.RiskInfo;
import com.shaoxi.risk.domain.service.RiskControlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class RiskControlServiceImpl implements RiskControlService {

    @Autowired
    private PromotionPriceCalAbility promotionPriceCalAbility;

    @Autowired
    private CostPriceQueryAbility costPriceQueryAbility;

    @Override
    public RiskInfo judeRisk(PriceRiskContext priceRiskContext) {
        RiskEvent riskEvent = priceRiskContext.getRiskEvent();
        PriceRiskReq priceRiskReq = priceRiskContext.getPriceRiskReq();

        //计算到手价
        Long handPrice = promotionPriceCalAbility.calPromotionPrice(riskEvent.getBizCode(), priceRiskReq);

        //获取成本价
        costPriceQueryAbility.queryCostPrice(priceRiskReq.getItemId(), priceRiskReq.getSkuId());

        //TODO 后续其他流程处理，居于到手价+成本价+风险判断规则进行风险识别

        return null;
    }

    @Override
    public RiskDisposalResult disposalRisk(RiskEvent riskEvent, RiskInfo riskInfo) {
        //TODO 实现
        return null;
    }


}
